<template>
  <div>
    <header>类别管理--添加分类</header>
    <div class="content">
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        
        <el-form-item label="所说品类">
          <el-select v-model="formInline.category" placeholder="活动区域">
            <el-option :label="item.name" :value="item.id" v-for="(item, index) in categoryList" :key="index"></el-option>
          </el-select>
        </el-form-item>

        <br>
        <br>

        <el-form-item label="品类名称">
          <el-input v-model="formInline.name" placeholder="品类名称"></el-input>
        </el-form-item>
        
        <br>
        <br>

        <el-form-item >
          <el-button type="primary" @click="onSubmit">提交</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import {category,addCategory} from '../../util/netWork';
export default {
  methods: {
    onSubmit() {
    //   console.log(this.formInline);
      var data={
          parentId:this.formInline.category,
          categoryName:this.formInline.name
      };
      addCategory(data).then(res=>{
          if(res.status==0){
              alert(res.data);
              this.$router.push("/ShopClassManage")
          }else{
              alert(res.data)
          }
      })
    }
  },
  data() {
    return {
      formInline: {
        name: "",
        category: "所有"
      },
      categoryList:[]
    };
  },
  mounted(){
      category().then(res=>{
          if(res.status==0){
              this.categoryList=res.data;
            //   console.log(res.data)
          }else{
              alert(res.data)
          }
      })
  }
};
</script>

<style lang="scss" scoped>
@import "@/assets/mixinScss.scss";
header {
  @include FontSize(30px);
  @include Size(100%, 100px);
  line-height: 100px;
  box-sizing: border-box;
  padding-left: 20px;
}
.content{
    text-align: center;
    
}
</style>